#
# FTSS - FullText Search System
#
# Cmake configuration file
#
#
PROJECT(FTSS)

SET(FTSS_VERSION_MAJOR 0)
SET(FTSS_VERSION_MINOR 1)
SET(FTSS_VERSION_PATCH 1)

CMAKE_MINIMUM_REQUIRED(VERSION 2.4.2 FATAL_ERROR)

OPTION(USE_AOT_LEMMATIZER "Enable AOT Lemmatizer support [default: OFF]" ON)
OPTION(DEBUG_MODE "Enable debug output [default: OFF]" ON)
OPTION(ENABLE_OPTIMIZATION "Enable optimization [default: OFF]" OFF)

# ################################################################################
# Check Includes
#
INCLUDE(CheckIncludeFiles)
INCLUDE(CheckCXXSourceCompiles)
INCLUDE(CheckFunctionExists)
INCLUDE(CheckSymbolExists)
INCLUDE(CheckLibraryExists)

CHECK_LIBRARY_EXISTS(m round    " " HAVE_ROUND_FN)
CHECK_LIBRARY_EXISTS(m roundl   " " HAVE_ROUNDL_FN)

CHECK_INCLUDE_FILES(sys/types.h HAVE_SYS_TYPES_H)
CHECK_INCLUDE_FILES(sys/time.h  HAVE_SYS_TIME_H)
CHECK_INCLUDE_FILES(sys/uio.h   HAVE_SYS_UIO_H)

CHECK_INCLUDE_FILES(fcntl.h     HAVE_FCNTL_H)
CHECK_INCLUDE_FILES(math.h      HAVE_MATH_H)
CHECK_INCLUDE_FILES(stdio.h     HAVE_STDIO_H)
CHECK_INCLUDE_FILES(stdlib.h    HAVE_STDLIB_H)
CHECK_INCLUDE_FILES(string.h    HAVE_STRING_H)
CHECK_INCLUDE_FILES(time.h      HAVE_TIME_H)
CHECK_INCLUDE_FILES(unistd.h    HAVE_UNISTD_H)
CHECK_INCLUDE_FILES(sysexits.h  HAVE_SYSEXITS_H)

CHECK_CXX_SOURCE_COMPILES("#include <map>
                           int main(void)
                           {
                               std::map<int, int> m;
                               m.insert(std::pair<int, int>(1, 2));
                               m[2] = 3;
                               return 0;
                           }
                          " STL_MAP_CHECK)
IF(NOT STL_MAP_CHECK)
    MESSAGE(STATUS "!!!! STL std::map does not work!")
ENDIF(NOT STL_MAP_CHECK)

CHECK_CXX_SOURCE_COMPILES("#include <vector>
                           int main(void)
                           {
                               std::vector<int> v;
                               v.push_back(1);
                               return 0;
                           }
                          " STL_VECTOR_CHECK)
IF(NOT STL_VECTOR_CHECK)
    MESSAGE(STATUS "!!!! STL std::vector does not work!")
ENDIF(NOT STL_VECTOR_CHECK)

CHECK_CXX_SOURCE_COMPILES("#include <string>
                           int main(void)
                           {
                               std::string s;
                               s.assign(\"Hello, World!\");
                               return 0;
                           }
                          " STL_STRING_CHECK)

IF(NOT STL_STRING_CHECK)
    MESSAGE(STATUS "!!!! STL std::string does not work!")
ENDIF(NOT STL_STRING_CHECK)

CHECK_CXX_SOURCE_COMPILES("#include <stdexcept>
                           int main(void)
                           {
                               try
                               {
                                   throw std::logic_error(\"Ouch!\");
                               }
                               catch(std::exception &e)
                               {
                                   return 0;
                               }
                               return 0;
                           }
                          " STL_STDEXCEPT_CHECK)

IF(NOT STL_STDEXCEPT_CHECK)
    MESSAGE(STATUS "!!!! STL std::logic_error/std::exception does not work!")
ENDIF(NOT STL_STDEXCEPT_CHECK)

CHECK_CXX_SOURCE_COMPILES("#include <vector>
                           int main(void)
                           {
                               vector<int> v;
                               v.push_back(1);
                               return 0;
                           }
                          " STL_VECTOR_NO_STD_CHECK)

IF(NOT STL_VECTOR_CHECK)
    IF (STL_VECTOR_NO_STD_CHECK)
        MESSAGE(STATUS "Using STL classes without STD namespace")
        SET(NO_STL_STD_PREFIX "ON")
    ENDIF (STL_VECTOR_NO_STD_CHECK)
ENDIF(NOT STL_VECTOR_CHECK)

# ################################################################################
# Libraries
#
IF("${USE_AOT_LEMMATIZER}" MATCHES "ON")
    MESSAGE(STATUS "#### AOT lemmatizer enabled.")
    MESSAGE(STATUS "#### You can disable support of AOT's lemmatizer library with flag USE_AOT_LEMMATIZER=OFF")
    MESSAGE(STATUS "#### ATTENTION #################################################")
    MESSAGE(STATUS "#### In order to process tests you shound set RML variable! ####")
    MESSAGE(STATUS "#### ATTENTION #################################################")
    FIND_PATH (LEMCLIENT_INCLUDE TurglemLemmatizer.h PATHS /opt/include/turglem
                                                     /usr/include/turglem                                                     
                                                     /usr/local/include/turglem                                                     
               DOC "Path where the LemClient header files can be found")

    IF (LEMCLIENT_INCLUDE)
        INCLUDE_DIRECTORIES(${LEMCLIENT_INCLUDE})
    ENDIF (LEMCLIENT_INCLUDE)

    FIND_LIBRARY(TURGLEM_LIBRARY NAMES turglem PATHS /opt/lib                                                         
                                                         /usr/lib                                                         
                                                         /usr/local/lib                                                         
                 DOC "Path where the LemClient libraries can be found")

    FIND_LIBRARY(TURGLEM_RUSSIAN_LIBRARY NAMES turglem-russian PATHS /opt/lib                                                         
                                                         /usr/lib                                                         
                                                         /usr/local/lib                                                         
                 DOC "Path where the LemClient libraries can be found")
                 
    FIND_LIBRARY(TURGLEM_ENGLISH_LIBRARY NAMES turglem-english PATHS /opt/lib                                                         
                                                         /usr/lib                                                         
                                                         /usr/local/lib                                                         
                 DOC "Path where the LemClient libraries can be found")
                 
                 
    FIND_LIBRARY(MAFSA_LIBRARY NAMES MAFSA PATHS /opt/lib                                                         
                                                         /usr/lib                                                         
                                                         /usr/local/lib                                                         
                 DOC "Path where the LemClient libraries can be found")
    
    SET(PROJECT_LIBS turglem)
    SET(PROJECT_LIBS turglem-russian)
    SET(PROJECT_LIBS turglem-english)
    SET(PROJECT_LIBS MAFSA)

    SET(AOT_LEMMATIZER_SRC src/TurglemLemmatizer.cpp)

ELSE("${USE_AOT_LEMMATIZER}" MATCHES "OFF")
     MESSAGE(STATUS "#### AOT lemmatizer disabled.")
     MESSAGE(STATUS "#### You can enable support of AOT's lemmatizer library with flag USE_AOT_LEMMATIZER=ON")
ENDIF("${USE_AOT_LEMMATIZER}" MATCHES "ON")

FIND_PATH(LIBEXPAT_INCLUDE expat.h PATHS /opt/include
                                         /usr/include
                                         /usr/local/include
          DOC "Path where the Expat header files can be found")

IF (LIBEXPAT_INCLUDE)
    INCLUDE_DIRECTORIES(${LIBEXPAT_INCLUDE})
ENDIF (LIBEXPAT_INCLUDE)

FIND_LIBRARY(LIBEXPAT_LIBRARY NAMES expat PATHS /opt/lib
                                                /usr/lib
                                                /usr/local/lib
             DOC "Path where the Expat libraries can be found")

SET(PROJECT_LIBS expat)

#
# Iconv converter support
#
FIND_PATH(ICONV_INCLUDE iconv.h PATHS /opt/include
                                      /usr/include
                                      /usr/local/include
          DOC "Path where the iconv header files can be found")

INCLUDE_DIRECTORIES(${ICONV_INCLUDE})

IF (NOT "${SKIP_ICONV_LIRARY}" MATCHES "ON")
    FIND_LIBRARY(ICONV_LIBRARY NAMES iconv PATHS /lib
                                                 /opt/lib
                                                 /usr/lib
                                                 /usr/local/lib
                 DOC "Path where the openssl libraries can be found")
    IF (ICONV_LIBRARY)
        SET(PROJECT_LIBS "${PROJECT_LIBS} iconv")
    ELSE (ICONV_LIBRARY)
        MESSAGE(STATUS "#### ERROR: Cannot find libiconv.so, aborting")
    ENDIF (ICONV_LIBRARY)
ENDIF (NOT "${SKIP_ICONV_LIRARY}" MATCHES "ON")


FIND_LIBRARY(MATH_LIBRARY NAMES m PATHS /opt/lib
                                        /usr/lib
                                        /usr/local/lib
             DOC "Path where the math libraries can be found")

FIND_PATH(LIBREADLINE_INCLUDE readline/readline.h PATHS /opt/include
                                                        /usr/include
                                                        /usr/local/include
          DOC "Path where the Readline header files can be found")

IF (LIBREADLINE_INCLUDE)
    INCLUDE_DIRECTORIES(${LIBREADLINE_INCLUDE})

    FIND_LIBRARY(LIBREADLINE_LIBRARY NAMES readline PATHS /lib
                                                          /opt/lib
                                                          /usr/lib
                                                          /usr/local/lib
                 DOC "Path where the Readline libraries can be found")
    SET(PROJECT_LIBS readline)

IF(NOT "${CMAKE_SYSTEM_NAME}" MATCHES "Linux")

    FIND_LIBRARY(LIBTERMCAP_LIBRARY NAMES termcap PATHS /lib
                                                        /opt/lib
                                                        /usr/lib
                                                        /usr/local/lib
                 DOC "Path where the Termcap libraries can be found")
    SET(PROJECT_LIBS termcap)

ENDIF(NOT "${CMAKE_SYSTEM_NAME}" MATCHES "Linux")

    SET(USE_LIBREADLINE "ON")
ENDIF (LIBREADLINE_INCLUDE)

IF("${USE_LIBREADLINE}" MATCHES "ON")
    MESSAGE(STATUS "#### INFO ######################################################")
    MESSAGE(STATUS "#### Readline support enabled.                              ####")
    MESSAGE(STATUS "#### INFO ######################################################")
ENDIF("${USE_LIBREADLINE}" MATCHES "ON")

MESSAGE(STATUS "#### System name is: ${CMAKE_SYSTEM_NAME}")

IF("${CMAKE_SYSTEM_NAME}" MATCHES "FreeBSD")
    MESSAGE(STATUS "#### Building for FreeBSD...")
ENDIF("${CMAKE_SYSTEM_NAME}" MATCHES "FreeBSD")

IF("${CMAKE_SYSTEM_NAME}" MATCHES "Linux")
    SET(SKIP_ICONV_LIRARY   "ON")
    MESSAGE(STATUS "#### Building for Linux...")
ENDIF("${CMAKE_SYSTEM_NAME}" MATCHES "Linux")

IF("${CMAKE_SYSTEM_NAME}" MATCHES "SunOS")
    MESSAGE(STATUS "#### Building for SunOS...")
ENDIF("${CMAKE_SYSTEM_NAME}" MATCHES "SunOS")

IF("${CMAKE_SYSTEM_NAME}" MATCHES "HP-UX")
    MESSAGE(STATUS "#### Building for HP-UX...")
ENDIF("${CMAKE_SYSTEM_NAME}" MATCHES "HP-UX")

INCLUDE_DIRECTORIES(include)

IF("${CMAKE_COMPILER_IS_GNUCXX}" MATCHES "1")

    SET(CMAKE_CXX_PARAMS " --param large-function-growth=5000 --param inline-unit-growth=200 ")

    SET(CMAKE_CXX_WARN_FLAGS " -Wall -pedantic -Wno-long-long -Winline -finline-functions ")

    IF(ENABLE_OPTIMIZATION MATCHES "ON")
        SET(CMAKE_CXX_FLAGS "${CXX_FLAGS} ${CMAKE_CXX_WARN_FLAGS} ${CMAKE_CXX_PARAMS} -O3 -fomit-frame-pointer -funroll-loops ")
    ELSE(ENABLE_OPTIMIZATION MATCHES "OFF")
        SET(CMAKE_CXX_FLAGS "${CXX_FLAGS} ${CMAKE_CXX_WARN_FLAGS} ${CMAKE_CXX_PARAMS} ")
    ENDIF(ENABLE_OPTIMIZATION MATCHES "ON")

    IF(DEBUG_MODE MATCHES "ON")
        SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g ")
    ENDIF(DEBUG_MODE MATCHES "ON")

ENDIF("${CMAKE_COMPILER_IS_GNUCXX}" MATCHES "1")

IF(ENABLE_OPTIMIZATION MATCHES "ON")
    MESSAGE(STATUS "#### Optimized build mode enabled")
ELSE(ENABLE_OPTIMIZATION MATCHES "OFF")
    MESSAGE(STATUS "#### Optimized build mode disabled")
ENDIF(ENABLE_OPTIMIZATION MATCHES "ON")

IF(DEBUG_MODE MATCHES "ON")
    MESSAGE(STATUS "#### ATTENTION #################################################")
    MESSAGE(STATUS "#### Debug mode enabled. Use this option only for testing!  ####")
    MESSAGE(STATUS "#### ATTENTION #################################################")
ENDIF(DEBUG_MODE MATCHES "ON")

# ################################################################################
# Sources
#
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/SysHeaders.h.cmake ${CMAKE_CURRENT_SOURCE_DIR}/include/SysHeaders.h)
#
SET(LIBSRCS ${AOT_LEMMATIZER_SRC}
	    src/CharTables.cpp
            src/DefaultLemmatizerInterface.cpp
            src/DefaultRanker.cpp
            src/Document.cpp
            src/FSDumper.cpp
            src/FileDocumentStorage.cpp
            src/HTMLDocumentParser.cpp
            src/Indexer.cpp
            src/IRConfig.cpp
            src/LemCache.cpp
            src/MemoryDocumentInfoStorage.cpp
            src/MemoryInvIndexStorage.cpp
            src/Passage.cpp
            src/PlaintextParser.cpp
            src/QueryParser.cpp
            src/RankedDocument.cpp
            src/Retriever.cpp
            src/SnippetCollector.cpp
            src/StopWords.cpp
            src/TimeProfiler.cpp
            src/Util.cpp
            src/XMLConfigHandler.cpp
            src/XMLDocumentParser.cpp
            src/XMLParser.cpp
	    src/UnicodeUtils.cpp
	    src/CompressorDocumentStorages.cpp
            src/PrefixTree.cpp
	    src/Storage.cpp
	    src/InvIndexBPlusStorage.cpp
            )

# ################################################################################
# Lib binary
#
ADD_LIBRARY(ir-static STATIC ${LIBSRCS})
SET_TARGET_PROPERTIES(ir-static PROPERTIES OUTPUT_NAME ir-st)
SET_TARGET_PROPERTIES(ir-static PROPERTIES LINKER_LANGUAGE CXX)

ADD_LIBRARY(ir SHARED ${LIBSRCS})
SET_TARGET_PROPERTIES(ir PROPERTIES OUTPUT_NAME ir)
SET_TARGET_PROPERTIES(ir PROPERTIES LINKER_LANGUAGE CXX)
SET_TARGET_PROPERTIES(ir PROPERTIES VERSION ${FTSS_VERSION_MAJOR}.${FTSS_VERSION_MINOR}.${FTSS_VERSION_PATCH} SOVERSION ${FTSS_VERSION_MAJOR})

# ################################################################################
# Exec binary
#

# Stopwords database
ADD_EXECUTABLE(StopWordsDB src/StopWordsDB.cpp)
TARGET_LINK_LIBRARIES(StopWordsDB ir ${TURGLEM_LIBRARY} ${TURGLEM_RUSSIAN_LIBRARY} ${TURGLEM_ENGLISH_LIBRARY} ${MAFSA_LIBRARY} ${LIBEXPAT_LIBRARY} ${ICONV_LIBRARY})

# Indexer
ADD_EXECUTABLE(Indexer src/IndexerWorker.cpp)
TARGET_LINK_LIBRARIES(Indexer ir ${TURGLEM_LIBRARY} ${TURGLEM_RUSSIAN_LIBRARY} ${TURGLEM_ENGLISH_LIBRARY} ${MAFSA_LIBRARY} ${LIBEXPAT_LIBRARY} ${ICONV_LIBRARY})

#Compressor
ADD_EXECUTABLE(DeleteAndCompress src/CompressorDocumentStoragesWorker.cpp)
TARGET_LINK_LIBRARIES(DeleteAndCompress ir ${TURGLEM_LIBRARY} ${TURGLEM_RUSSIAN_LIBRARY} ${TURGLEM_ENGLISH_LIBRARY} ${MAFSA_LIBRARY} ${LIBEXPAT_LIBRARY} ${ICONV_LIBRARY} ${ICONV_LIBRARY})


#Prefix Tree
ADD_EXECUTABLE(PrefixTree src/PrefixTreeWorker.cpp)
TARGET_LINK_LIBRARIES(PrefixTree ir ${TURGLEM_LIBRARY} ${TURGLEM_RUSSIAN_LIBRARY} ${TURGLEM_ENGLISH_LIBRARY} ${MAFSA_LIBRARY} ${LIBEXPAT_LIBRARY} ${ICONV_LIBRARY})

# JUST FOR DEBUG DELETE AFTER DEBUGGING
# BPlusTreeNodeStorage
ADD_EXECUTABLE(BPlusTreeNodeStorage    src/BPlusTreeStorageWorker.cpp)
TARGET_LINK_LIBRARIES(BPlusTreeNodeStorage ir ${TURGLEM_LIBRARY} ${TURGLEM_RUSSIAN_LIBRARY} ${TURGLEM_ENGLISH_LIBRARY} ${MAFSA_LIBRARY} ${LIBEXPAT_LIBRARY} ${ICONV_LIBRARY})

# JUST FOR DEBUG DELETE AFTER DEBUGGING
# BPlusTreeNodeStorage
#ADD_EXECUTABLE(InvIndexBPlusStorage     src/InvIndexBPlusStorage.cpp )
#TARGET_LINK_LIBRARIES(InvIndexBPlusStorage  ir ${TURGLEM_LIBRARY} ${TURGLEM_RUSSIAN_LIBRARY} ${TURGLEM_ENGLISH_LIBRARY} ${MAFSA_LIBRARY} ${LIBEXPAT_LIBRARY} ${ICONV_LIBRARY})


# ################################################################################
# Test suite
#
ENABLE_TESTING()

ADD_EXECUTABLE(AllocatorTest       tests/AllocatorTest.cpp)

#ADD_EXECUTABLE(BTreeTest           tests/BTreeTest.cpp)
#ADD_EXECUTABLE(BPlusTreeTest       tests/BPlusTreeTest.cpp)

ADD_EXECUTABLE(HashTest            tests/HashTest.cpp)

ADD_EXECUTABLE(HashFunction        tests/HashFunctionTest.cpp)

#ADD_EXECUTABLE(WordSplitterTest    tests/WordSplitterTest.cpp src/WordSplitter.cpp)

ADD_EXECUTABLE(LemCacheTest        tests/LemCacheTest.cpp)
TARGET_LINK_LIBRARIES(LemCacheTest ir ${TURGLEM_LIBRARY} ${TURGLEM_RUSSIAN_LIBRARY} ${TURGLEM_ENGLISH_LIBRARY} ${MAFSA_LIBRARY} ${LIBEXPAT_LIBRARY} ${ICONV_LIBRARY})

ADD_EXECUTABLE(QueryParserTest     tests/QueryParserTest.cpp)
TARGET_LINK_LIBRARIES(QueryParserTest ${MATH_LIBRARY} ir ${TURGLEM_LIBRARY} ${TURGLEM_RUSSIAN_LIBRARY} ${TURGLEM_ENGLISH_LIBRARY} ${MAFSA_LIBRARY}  ${LIBEXPAT_LIBRARY} ${ICONV_LIBRARY})

ADD_EXECUTABLE(ComplexQueryTest    tests/ComplexQueryTest.cpp)
TARGET_LINK_LIBRARIES(ComplexQueryTest ${MATH_LIBRARY} ir ${TURGLEM_LIBRARY} ${TURGLEM_RUSSIAN_LIBRARY} ${TURGLEM_ENGLISH_LIBRARY} ${MAFSA_LIBRARY}  ${LIBEXPAT_LIBRARY} ${ICONV_LIBRARY})

ADD_EXECUTABLE(TimeProfilerTest    tests/TimeProfilerTest.cpp)
TARGET_LINK_LIBRARIES(TimeProfilerTest ir ${TURGLEM_LIBRARY} ${TURGLEM_RUSSIAN_LIBRARY} ${TURGLEM_ENGLISH_LIBRARY} ${MAFSA_LIBRARY} ${LIBEXPAT_LIBRARY} ${ICONV_LIBRARY} )

ADD_EXECUTABLE(ConfigTest          tests/ConfigTest.cpp)
TARGET_LINK_LIBRARIES(ConfigTest ${MATH_LIBRARY} ir ${TURGLEM_LIBRARY} ${TURGLEM_RUSSIAN_LIBRARY} ${TURGLEM_ENGLISH_LIBRARY} ${MAFSA_LIBRARY}  ${LIBEXPAT_LIBRARY} ${ICONV_LIBRARY})

ADD_EXECUTABLE(ConfigFileTest      tests/ConfigFileTest.cpp)
TARGET_LINK_LIBRARIES(ConfigFileTest ${MATH_LIBRARY} ir ${TURGLEM_LIBRARY} ${TURGLEM_RUSSIAN_LIBRARY} ${TURGLEM_ENGLISH_LIBRARY} ${MAFSA_LIBRARY} ${LIBEXPAT_LIBRARY} ${ICONV_LIBRARY})

ADD_EXECUTABLE(QuorumFunctions     tests/QuorumFunctions.cpp)
TARGET_LINK_LIBRARIES(QuorumFunctions ${MATH_LIBRARY})

ADD_EXECUTABLE(OutputDataCollectorTest tests/OutputDataCollectorTest.cpp)

ADD_EXECUTABLE(Retriever src/RetrieverWorker.cpp src/ReadLine.cpp)
TARGET_LINK_LIBRARIES(Retriever ir ${TURGLEM_LIBRARY} ${TURGLEM_RUSSIAN_LIBRARY} ${TURGLEM_ENGLISH_LIBRARY} ${MAFSA_LIBRARY} ${LIBEXPAT_LIBRARY} ${ICONV_LIBRARY} ${LIBREADLINE_LIBRARY} )

ADD_EXECUTABLE(RetrieverTest tests/RetrieverWorker.cpp)
TARGET_LINK_LIBRARIES(RetrieverTest ir ${TURGLEM_LIBRARY} ${TURGLEM_RUSSIAN_LIBRARY} ${TURGLEM_ENGLISH_LIBRARY} ${MAFSA_LIBRARY}  ${LIBEXPAT_LIBRARY} ${ICONV_LIBRARY})

ADD_EXECUTABLE(DocumentEntryContainerTest tests/DocumentEntryContainerTest.cpp)

ADD_EXECUTABLE(DocumentTest tests/DocumentTest.cpp)
TARGET_LINK_LIBRARIES(DocumentTest ir ${TURGLEM_LIBRARY} ${TURGLEM_RUSSIAN_LIBRARY} ${TURGLEM_ENGLISH_LIBRARY} ${MAFSA_LIBRARY}  ${LIBEXPAT_LIBRARY} ${ICONV_LIBRARY})

ADD_EXECUTABLE(DocumentStorageTest tests/DocumentStorageTest.cpp)
TARGET_LINK_LIBRARIES(DocumentStorageTest ir ${TURGLEM_LIBRARY} ${TURGLEM_RUSSIAN_LIBRARY} ${TURGLEM_ENGLISH_LIBRARY} ${MAFSA_LIBRARY} ${LIBEXPAT_LIBRARY} ${ICONV_LIBRARY})

ADD_EXECUTABLE(DocumentBuilderTest tests/DocumentBuilderTest.cpp)

ADD_EXECUTABLE(ParsersTest         tests/ParsersTest.cpp)
TARGET_LINK_LIBRARIES(ParsersTest ir ${TURGLEM_LIBRARY} ${TURGLEM_RUSSIAN_LIBRARY} ${TURGLEM_ENGLISH_LIBRARY} ${MAFSA_LIBRARY} ${LIBEXPAT_LIBRARY} ${ICONV_LIBRARY})

ADD_EXECUTABLE(DeleteAndCompressTest         src/CompressorDocumentStoragesWorker.cpp)
TARGET_LINK_LIBRARIES(DeleteAndCompressTest ir ${TURGLEM_LIBRARY} ${TURGLEM_RUSSIAN_LIBRARY} ${TURGLEM_ENGLISH_LIBRARY} ${MAFSA_LIBRARY} ${LIBEXPAT_LIBRARY} ${ICONV_LIBRARY})


ADD_EXECUTABLE(BPlusStorageTest         tests/BPlusTreeStorageTest.cpp)
TARGET_LINK_LIBRARIES(BPlusStorageTest ir ${TURGLEM_LIBRARY} ${TURGLEM_RUSSIAN_LIBRARY} ${TURGLEM_ENGLISH_LIBRARY} ${MAFSA_LIBRARY} ${LIBEXPAT_LIBRARY} ${ICONV_LIBRARY})


ADD_TEST(AllocatorTest               AllocatorTest)
#ADD_TEST(BPlusTreeTest               BPlusTreeTest)
#ADD_TEST(BTreeTest                   BTreeTest)
ADD_TEST(HashTest                    HashTest)
ADD_TEST(HashFunction                HashFunction "проверка")
ADD_TEST(QueryParserTest             QueryParserTest  "на поле ^ (танки | грохотали)")
ADD_TEST(TimeProfilerTest            TimeProfilerTest)
ADD_TEST(ConfigTest                  ConfigTest)
ADD_TEST(QuorumFunctions             QuorumFunctions)
ADD_TEST(OutputDataCollectorTest     OutputDataCollectorTest)
ADD_TEST(StopWordsTest               StopWordsDB stopwords.txt data/StopWords.ftss)
ADD_TEST(Indexer                     Indexer plaintext tests/filelist_1.txt data/)
ADD_TEST(ParsersTest                 ParsersTest tests/text/simple.txt tests/text/simple1.txt tests/text/simpl2.txt)
ADD_TEST(ComplexQueryTest            ComplexQueryTest data/InvIndex.ftss data/StopWords.ftss "на поле ^ (танки | грохотали)")
ADD_TEST(Retriever                   Retriever plaintext data/ conf/ftss.xml.conf "на поле ^ (танки | грохотали)")
ADD_TEST(DocumentEntryContainerTest  DocumentEntryContainerTest)
ADD_TEST(DocumentTest                DocumentTest)
ADD_TEST(DocumentStorageTest         DocumentStorageTest)
ADD_TEST(DocumentBuilderTest         DocumentBuilderTest)
ADD_TEST(CompressorTest  	     DeleteAndCompressTest data/ tests/delete_id.txt)
ADD_TEST(BPlusStorageTest  	     BPlusStorageTest data/ )

# Install Headers
INSTALL(FILES
              include/AOTLemmatizerInterface.hpp
              include/Allocator.hpp
              include/BaseParser.hpp
	      include/BPlusTree.hpp
	      include/BPlusTree.tcc
	      include/BPlusNodeLeaf.hpp	
	      include/BPlusTreeLeafData.hpp
	      include/BPlusTreeLeafsStorage.hpp
	      include/BPlusTreeNodesStorage.hpp
	      include/BPlusTreeNodeData.hpp
              include/BitIndex.hpp
              include/BPlusCache.hpp
	      include/CharTables.hpp
              include/CharIterator.hpp
	      include/CompressorDocumentStorages.hpp
              include/DataDumper.hpp
              include/DefaultLemmatizerInterface.hpp
              include/DefaultRanker.hpp
              include/Document.hpp
              include/DocumentBuilder.hpp
              include/DocumentEntryContainer.hpp
              include/DocumentEntryIterator.hpp
              include/DocumentHelper.hpp
              include/DocumentInfo.hpp
              include/DocumentInfoStorage.hpp
              include/DocumentStorage.hpp
              include/FSDumper.hpp
              include/FTS.hpp
              include/FTSSException.hpp
              include/FTSTypes.h
              include/FileDocumentStorage.hpp
              include/GlobalDefines.h
              include/HTMLDocumentParser.hpp
              include/Hash.hpp
              include/Hash.tcc
              include/HashFunctions.hpp
              include/IRConfig.hpp
              include/IRIndexer.hpp
              include/IRSearch.hpp
              include/Indexer.hpp
	      include/InvIndexBPlusStorage.hpp
              include/InvIndexStorage.hpp
              include/LemCache.hpp
              include/LemmatizerInterface.hpp
              include/MemoryDocumentInfoStorage.hpp
              include/MemoryInvIndexStorage.hpp
              include/NodeStorage.hpp
              include/NumZones.hpp
              include/OutputDataCollector.hpp
              include/Pair.hpp
              include/ParseException.hpp
              include/Passage.hpp
              include/PlaintextParser.hpp
	      include/PrefixTree.hpp
              include/QueryParser.hpp
              include/RankedDocument.hpp
              include/Ranker.hpp
              include/ReadLine.hpp
              include/Retriever.hpp
              include/STLFunctional.hpp
              include/STLString.hpp
              include/STLVector.hpp
              include/SafePtr.hpp
              include/SnippetCollector.hpp
              include/StopWords.hpp
	      include/Storage.hpp
              include/SysHeaders.h
              include/TermStatistic.hpp
              include/TimeProfiler.hpp
              include/TurglemLemmatizer.hpp
              include/Types.h
	      include/UnicodeUtils.hpp
	      include/UnicodeUtils.tcc
              include/Util.hpp
              include/XMLConfigHandler.hpp
              include/XMLDocumentParser.hpp
              include/XMLHandler.hpp
              include/XMLParser.hpp
              include/ZoneInfo.hpp
        DESTINATION include/IR
        PERMISSIONS OWNER_READ OWNER_WRITE
                    GROUP_READ
                    WORLD_READ)

# Install library
INSTALL(TARGETS ir ir-static DESTINATION lib)

# Install binaries
INSTALL(FILES ConfigFileTest
              Indexer
              Retriever
              StopWordsDB
        DESTINATION bin
        PERMISSIONS OWNER_EXECUTE OWNER_READ OWNER_WRITE
                    GROUP_EXECUTE GROUP_READ
                    WORLD_EXECUTE WORLD_READ)
# End.
